#ifndef QUANTITY_H_
#define QUANTITY_H_
#include <LengthUnit.h>
#include <VolumeUnit.h>
#include <string>
#include <iostream>
using namespace std;

template <class TUnit>
class Quantity
{
	public:
		Quantity(unsigned int amount);
		Quantity(unsigned int amount, TUnit unit);
		bool operator == (const Quantity& quantity) const;
		Quantity<TUnit> operator + (const Quantity<TUnit>& quantity) const;
		void printQuantity(std::ostream& out, const TUnit* unitType) const;

	protected:
		unsigned int m_amount;
};

#define Length Quantity<LengthUnit>
#define Volume Quantity<VolumeUnit>

template <class TUnit>
Quantity<TUnit>::Quantity(unsigned int amount):m_amount(amount){}

template <class TUnit>
Quantity<TUnit>::Quantity(unsigned int amount, TUnit unit):m_amount(unit.toAmountOfBaseUnit(amount)){}

template <class TUnit>
bool Quantity<TUnit>::operator == (const Quantity& quantity) const
{
	return(m_amount == quantity.m_amount);
}

template <class TUnit>
Quantity<TUnit> Quantity<TUnit>::operator + (const Quantity<TUnit>& quantity) const
{
	return(Quantity(m_amount + quantity.m_amount));
}

template <class TUnit>
void Quantity <TUnit>::printQuantity(std::ostream& out, const TUnit* unitType) const
{
	unsigned int i, amount = m_amount;

	for(i=0;i < sizeof(unitType);i++) {
		unitType[i].printAmountPerUnit(out, amount);
	}
	out<<endl;
}


#endif
